package cn.platform.mapper;

import cn.platform.entity.Teacher;
import cn.platform.entity.UserAccount;
import cn.platform.request.IdentifyRequest;
import cn.platform.request.TeacherRequest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TeacherMapper1 {
    // 登录身份验证
    List<UserAccount> identify(IdentifyRequest req);

    // 查询
    List<Teacher> listTeacher(TeacherRequest req);

    // 新增
    void insertTeacher(TeacherRequest req);

    // 更新，用id找，其余参数为更新内容，null值不更新
    void updateTeacher(Teacher teacher);

    @Select("select real_name from jxt_teachers where id=#{pubId}")
    String getNameById(Integer pubId);

//    Page<UserTeacherVO> page(UserTeacherQueryDTO userTeacherQueryDTO);

    @Insert("insert into jxt_teachers(username, password, sex, real_name, job_title, status) VALUES (#{username},#{password},#{sex},#{realName},#{jobTitle},#{status})")
    void insert(Teacher teacher);

    Integer countTeacherId(List<Integer> ids);

    @Delete("delete from jxt_teachers where id=#{id}")
    void deleteById(Integer id);

    void batchDeleteByIds(List<Integer> ids);


    //关联学生成绩
    Teacher getById(Integer pubId);
    @Select("SELECT id, real_name FROM jxt_teachers WHERE real_name LIKE CONCAT('%', #{name}, '%')")
    List<Teacher> searchByName(String name);

    @Select("SELECT id, real_name FROM jxt_teachers")
    List<Teacher> getAll();
}
